package com.free.mysql.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import com.free.freemarker.constant.SqlConstant;

public class MySqlConnection {
//
//    public Connection createConnection() throws Exception {
//        Class.forName(SqlConstant.SQL_DRIVER).newInstance();
//        Connection con = DriverManager.getConnection(SqlConstant.SQL_URL, SqlConstant.USER, SqlConstant.PASSWORD);
//        return con;
//    }

    public Connection createConnection() throws InstantiationException,
            IllegalAccessException, ClassNotFoundException, SQLException {
        Class.forName(SqlConstant.SQL_DRIVER).newInstance();
        Properties props = new Properties();
        props.setProperty("user", SqlConstant.USER);
        props.setProperty("password", SqlConstant.PASSWORD);
        props.setProperty("remarks", "true");
        props.setProperty("useInformationSchema", "true");// 设置可以获取tables
        // remarks信息
        Connection con = DriverManager.getConnection(SqlConstant.SQL_URL, props);
        return con;
    }
}
